
<div class="profileleve">
 <form id="formConnexion" name="formprofileleve" action="<?php echo base_url()."index.php/profileleve/index";?>" method="POST">
    <span class="titleSection">Profil de l'&eacute;l&egrave;ve :</span>
    
    <p><i>Veuillez corriger les informations ci-dessous si elles sont inexactes. 
          <br/><b>Les champs comportant une * sont obligatoires</b></i></p><br/>

    <div class="champFormulaire">
		
		<p><span>Login * </span><?php echo $infos->login; ?><br/></p>
		<p><span>Pr&eacute;nom * </span><input type="text" id="prenom" name="prenom" value="<?php echo $infos->prenom; ?>" /><br/></p>
		<p><span>Nom * </span><input type="text" id="nom" name="nom" value="<?php echo $infos->nom; ?>" /><br/></p>
		<p><span>E-mail * </span><input type="text" id="email" name="email" value="<?php echo $infos->email; ?>" /><br/></p>
		<p><span>Ville * </span><input type="text" id="ville" name="ville" value="<?php echo $infos->ville; ?>" /><br/></p>
		
        <p><u>S&eacute;lectionnez votre formation :</u></p>
		<select id="ListeFormationProfil" name="ListeFormationProfil" class="select"> 
		<?php
			echo '<option value="-1" '.set_select('ListeFormationProfil', '-1').'></option>';
			foreach ($listeFormation as $row)
			{
				$isDefaut = false;
				if ($row->idformation == $infos->formation_idformation) {
					$isDefaut = true;
				}
				echo '<option value="' . $row->idformation . '" '.set_select('ListeFormationProfil', $row->idformation, $isDefaut).'>' . $row->nom . "</option>";
			}
		?>			
		</select><br/>
                
		<p><u>S&eacute;lectionnez vos modules :</u></p>
		
		<div id="listeCheckModule">
		<?php
		foreach ($listeModArray as $m) {
			
			$isDefaut = false;
			if (isset($listeModUserArray[$m->idmodule])) {
				$isDefaut = true;
			}
			
			echo '<input type="checkbox" name="modules[]" value="'.$m->idmodule.'" '.set_checkbox('modules[]', $m->idmodule, $isDefaut).' /> ';
			echo $m->nom;
			echo '<br>';
			
		}
		?>
		</div>
	
		<p>
			<a href="<?php echo base_url() ?>index.php/Modifmdp"><b>Acc&eacute;der &agrave la modification du mot de passe</b></a>
		</p>
                         
		<input type="submit" id="btnValiderProfil" value="Modifier"/>
    </div>
	
	<?php 
	echo validation_errors();
    ?>
	
    <div id="idErrorProfil" class="errorProfil"><span></span></div>
</form>
</div>
<script type="text/javascript">
	var listeModArray = <?php echo $listeModArrayJson; ?>;
	var listeModUserArray = <?php echo $listeModUserArrayJson; ?>;
	
$(function() {
	
	$("#ListeFormationProfil").change(function() {
		var fid = $(this).val();
		
		$("#listeCheckModule").empty();
			
		if (listeModArray[fid] !== undefined) {
			
			$.each(listeModArray[fid], function() {
				
				var html = '<input type="checkbox" name="modules[]" value="'+this.id+'"';
				
				if (listeModUserArray[this.id] !== undefined) {
					html += ' checked ';
				}
				
				html += '/> ';
				html += this.nom+'<br>';
				
				$("#listeCheckModule").append(html);
			});
		}
		
	});
	
	
});
</script>
